package com.example.personnel_oa.controller;
//Controler负责请求转发，接受页面过来的参数，传给Service处理，接到返回值，再传给页面。

import com.example.comment_oa.pojos.Recruits;
import com.example.comment_oa.pojos_vo.zff.RecruitsVo;
import com.example.comment_oa.response.AjaxResponse;
import com.example.personnel_oa.service.RecruitsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@Controller
@RequestMapping("/personnelOa")
public class RecruitsController {
    @Autowired
    RecruitsService recruitsService;
    @GetMapping ("/recruits/allrec")
    public AjaxResponse Methods_rec(){
        return AjaxResponse.success(recruitsService.Methods_rec());
    }

    @GetMapping("/recruits/allRecruits")
    public AjaxResponse allRecruits(){return AjaxResponse.success(recruitsService.allRecruits());}

    @GetMapping("/recruits/allrecruits/{recId}")
    public AjaxResponse allrecruits(@PathVariable("recId") int recId){
        return AjaxResponse.success(recruitsService.allrecruits(recId));
    }
    //查询入职员工详情
    @GetMapping("/recruits/allrecruits2/{recId}")
    public AjaxResponse allrecruits2(@PathVariable("recId") int recId){
        return AjaxResponse.success(recruitsService.allRecruits2(recId));
    }
    //才人入职成功后修改入职状态
    @PutMapping("/recruits/xiugaiState/{recId}/{empId}")
    public AjaxResponse xiugaiState(@PathVariable("recId") int recId,@PathVariable("empId") int empId){
        int upstate = recruitsService.upstate(recId,empId);
        return AjaxResponse.success(upstate);
    }
    //查询已入职记录
    @PostMapping("/recruits/allRecruits3")
    public AjaxResponse allRecruits3(@RequestBody RecruitsVo recruitsVo){
        System.err.println(recruitsVo);
        return AjaxResponse.success(recruitsService.allRecruits3(recruitsVo));
    }

    //新增待入职信息
    @PostMapping("/recruits/addrecruits")
    public AjaxResponse addrecruits(@RequestBody Recruits recruits){
        System.err.println(recruits);
        return AjaxResponse.success(recruitsService.addrecruits(recruits));
    }
}
